home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
rjs.lha
/
RJS
/
String
/
tests
/
ttrunc.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-14
|
638b
|
30 lines
#include "test.h"
void Trunc()
{
String s1("1234567890");
String s2("csdf");
String s3("a");
Assert(trunc(s1,5)=="12345");
Assert(trunc(s1,0)=="");
Assert(trunc(s1,-12)==s1);
Assert(trunc(s1,100)==s1);
Assert(trunc("123456",2)=="12");
Assert(trunc("asdsadas",0)=="");
Assert(trunc("abc",-12)=="abc");
Assert(trunc("abc",100)=="abc");
Assert(s1.trunc(5)=="12345"); s1.VERIFY();
Assert(s2.trunc(0)==""); s2.VERIFY();
Assert(s3.trunc(-12)==s3); s3.VERIFY();
Assert(s3.trunc(100)==s3); s3.VERIFY();
s1="this is a stupid test";
Assert(s1.at("stupid").trunc(3)=="stu");
Assert(s1=="this is a stu test");
}